﻿#pragma once
#include "CoreMinimal.h"
#include "GameplayEffectTypes.h"
#include "AuraProjectile.generated.h"

class USphereComponent;
class UProjectileMovementComponent;
class UNiagaraSystem;
UCLASS()
class AAuraProjectile : public AActor
{
	GENERATED_BODY()
public:
	AAuraProjectile();

	UPROPERTY(VisibleAnywhere,BlueprintReadOnly)
	UProjectileMovementComponent * ProjectileMovementComp;

	UPROPERTY(BlueprintReadWrite,meta=(ExposeOnSpawn=true))
	FGameplayEffectSpecHandle DamageEffectSpecHandle;
protected:
	virtual void BeginPlay() override;
	virtual void Destroyed() override;
	UFUNCTION()
	void OnSphereOverlap(UPrimitiveComponent* OverlappedComponent,
		AActor* OtherActor,
		UPrimitiveComponent* OtherComp,
		int32 OtherBodyIndex,
		bool bFromSweep,
		const FHitResult & SweepResult);
private:
	bool bHit = false;
	
	UPROPERTY(EditAnywhere,BlueprintReadOnly,meta=(AllowPrivateAccess = true))
	UAudioComponent* AudioComponent;
	
	UPROPERTY(EditAnywhere,BlueprintReadOnly,meta=(AllowPrivateAccess = true))
	USphereComponent* SphereComponent;
	UPROPERTY(EditAnywhere,BlueprintReadOnly,meta=(AllowPrivateAccess = true))
	float LifeSpanTime = 15.f;
	//冲击效果（收到攻击爆炸）
	UPROPERTY(EditAnywhere,BlueprintReadOnly,meta=(AllowPrivateAccess = true))
	TObjectPtr<UNiagaraSystem> ImpactEffect;
	
	//冲击音效（爆炸的声音）
	UPROPERTY(EditAnywhere,BlueprintReadOnly,meta=(AllowPrivateAccess = true))
	TObjectPtr<USoundBase> ImpactSound;

	//发射循环播放的音效
	UPROPERTY(EditAnywhere,BlueprintReadOnly,meta=(AllowPrivateAccess = true))
	TObjectPtr<USoundBase> LoopSound;
};